package com.itheima.list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class removeDemo1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("abc");
        list.add("def");
        list.add("ghi");

        Iterator<String> ite = list.iterator();

        while (ite.hasNext()) {  //判断迭代器中是否有元素
            String s = ite.next();    //变量s接收迭代器获取的集合元素
            if ("def".equals(s)) {
                ite.remove();
            }
        }
        System.out.println(list);
    }
}
